import { ChatOpenAI } from "@langchain/openai";
import { HumanMessage } from '@langchain/core/messages';

// process.env['OPENAI_API_KEY'] = "sk-9MmQUPP02CikLbmH76A85eDe9dF2433a8070D9D5EaDfA76e";
// process.env['OPENAI_BASE_URL'] = "https://gpt.0kk.top/v1/";

process.env['OPENAI_API_KEY'] = "sk-df50cc45c0ee4fc387486b8b42dbe73f";
process.env['OPENAI_BASE_URL'] = "https://api.deepseek.com/v1";

const chat = new ChatOpenAI({
    model: 'deepseek-chat',
});

const stream = await chat.stream([new HumanMessage({ content: "随机背诵一首中国古诗" })]);

const chunks = [];
for await (const chunk of stream) {
    chunks.push(chunk);
    console.log(`${JSON.stringify(chunk.content)}|`);
}
